package com.zfast.config.junit.sim;

import com.zfast.forge.pojo.dto.FieldSurface;
import org.apache.commons.codec.binary.Base64;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zgn
 * @Description: simJunit
 * @date 2022/1/13 0013
 */
public class uselessJunit {
    @Test
    public void egMax() {//e.g.
        //region 1.模拟数据
        System.out.println("--------------------Start--------------------");
        //endregion

        //region 2.数据处理
        System.out.println("--------------------Deal--------------------");
        //endregion

        //region 3.数据展示
        System.out.println("--------------------Done--------------------");
        //endregion
    }

    @Test
    public void egMin() {//e.g.
        System.out.println();
    }

    @Test
    //org.apache.commons.codec.binary.Base64 和com.sun.org.apache.xerces.internal.impl.dv.util.Base64
    public void 对比base64_egMin() {//e.g.
        String encodingAesKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
        byte[] bytes = Base64.decodeBase64(encodingAesKey + "=");

        byte[] decode = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.decode(encodingAesKey + "=");
        System.out.println(bytes);
        System.out.println(decode);
    }

    @Test
    public void 循环测试_egMin() {//e.g.
        List<FieldSurface> fieldSurfaces=new ArrayList<>();
        for (int i = 0; i < 9; i++) {
            FieldSurface fieldSurface =  FieldSurface.builder().name(""+i).build();
            fieldSurfaces.add(fieldSurface);
        }

        for (int i = 0; i < fieldSurfaces.size(); i++) {
            FieldSurface fieldSurface =  fieldSurfaces.get(i);

            if(fieldSurface.getName().equals("3")){
                break;
            }
            System.out.println(i);
        }
    }

    @Test
    public void 数学公式替换_egMin() {//e.g.
        String express=
                "(a+d*x+(o*x^2)/2-r)^2+" +
                "(b+e*x+(p*x^2)/2-s)^2+" +
                "(c+f*x+(q*x^2)/2-t)^2-" +
                "(v*x)^2";
        Map<String, Object> replaces = new HashMap();
        //2024年3月6日_1 真实数据
        /*replaces.put("a", 305);
        replaces.put("b", 936);
        replaces.put("c", -563);

        replaces.put("d", 0);
        replaces.put("e", 10.0179);
        replaces.put("f", 5.0089);

        replaces.put("o", 0);
        replaces.put("p", 0);
        replaces.put("q", "(-0.098)");

        replaces.put("r", 305);
        replaces.put("s", 1005);
        replaces.put("t", 800);

        replaces.put("v", 11.2000);*/

        //2024年3月6日_2 不考虑重力
        replaces.put("a", 305);
        replaces.put("b", 936);
        replaces.put("c", 1200);

        replaces.put("d", 0);
        replaces.put("e", 2);
        replaces.put("f", 1);

        replaces.put("o", 0);
        replaces.put("p", 0);
        replaces.put("q", 0);

        replaces.put("r", 305);
        replaces.put("s", 1005);
        replaces.put("t", 2500);

        replaces.put("v", 3);

        for (String s : replaces.keySet()) {
            express=express.replace(s,replaces.get(s).toString());
        }

        System.out.println(express);
    }
}
